package trainfengxing.controller;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import trainfengxing.pojo.Result;
import trainfengxing.pojo.order;

import java.util.List;

@Slf4j
@RestController
public class orderController {
     @Autowired
    private trainfengxing.service.orderService orderService;

     @PostMapping("/order")
    public Result order(@RequestBody order order){
        log.info("新购买的订单：{}", order);
//        调用servive
         orderService.order(order);
         return Result.success();
     }

     @GetMapping("/selectorder/{userID}")
    public Result selectorder(@PathVariable Integer userID){
//        调用servive
        List<order> orders = orderService.selectorder(userID);
         return Result.success(orders);
     }

     @DeleteMapping ("/deletetrainorder")
    public Result deletetrainorder(@RequestBody order order){
         log.info("删除订单：{}", order);
         orderService.deletetrainorder(order);
         return Result.success();
     }

     @PostMapping("/changeorder")
    public Result changeorder(@RequestBody order order){
         log.info("修改订单：{}", order);
         orderService.changeorder(order);
         return Result.success();
     }
}
